<template>
	<view>
		<an-nav-bar title="附近技师"> </an-nav-bar>
		<view class="technician-list">
			<block v-for="(item,index) in technicianList" :key="index">
				<view class="list-item" @click="gotoUrl(item)">
					<view class="item-left">
						<image v-if="item.headImg" class="head-img" :src="imgUrl+item.headImg" mode=""></image>
						<view class="far">距离较远=</view>
						<view class="state">
							<view class="">可预约=</view>
						</view>
					</view>
					<view class="item-right">
						<view class="t_name_tag_distance flex">
							<view class="flex t_name_tag">
								<view class="uni-label-pointer">{{item.nickName}}</view>
								<view class="t_tag">{{item.jobTitle}}</view>
							</view>
							<view class="flex t_distance">
								<uni-icons type="location-filled" color="#666" size="14"></uni-icons>
								<view>{{item.distance||''}}km</view>
							</view>
						</view>
						<view class="flex">
							<view class="t_left">
								<view class="t_certificate_order">
									<view class="flex">
										<view class="t_certificate flex iconfont">资质认证</view>
										<view class="">最近接单{{item.totalOrder||0}}单</view>
									</view>
									<view class="t_store flex iconfont">
										<view class="">水利宫养生=</view>
									</view>
								</view>
							</view>
							<button class="t_right_btn">预约</button>
						</view>
					</view>
				</view>
				<view class="technician-list_photos" @click="gotoUrl(item)">
					<view class="cells">
						<view class="cell" v-for="(img,i) in item.recentPhoto" :key="i">
							<image v-if="img" class="image" :src="imgUrl+img" mode="scaleToFill" ></image>
						</view>
					</view>
				</view>	
			</block>
		</view>
	</view>
</template>

<script>
	import indexConfig from '@/config/index.config';
	export default {
		data() {
			return {
				imgUrl: indexConfig.imgUrl,
				form: {
					storeId: '',
					accountType: 1,
					status: 1,
					latitude: "",
					longitude: ""
				},
				technicianList: []
			};
		},
		onLoad() {
			
		},	
		onShow() {
			let {
				location
			} = this.$mStore.state
			this.form.latitude=location.latitude
			this.form.longitude=location.longitude
			
			this.getList()
		},
		methods: {
			gotoUrl(item){
				uni.navigateTo({
					url:'/pages/technicianDetail/technicianDetail?id=' + item.id
				})
			},
			getList() {
				this.$http.get('/appNoAuth/store/massageTechnician/list', this.form).then(res => {
					console.log(res)
					this.technicianList = res.rows.map(val => {
						return {
							...val,
							recentPhoto: val.recentPhoto.split(',')
						}
					})
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.technician-list {
		width: 100%;
		margin-bottom: 10rpx;
		background-color: #f8f8f8;
		box-sizing: border-box;

		.list-item {
			width: 100%;
			background-color: #666;
			box-sizing: border-box;
			background: #fff;
			padding: 24rpx 28rpx 0;
			display: flex;
			align-items: flex-start !important;

			.item-left {
				width: 126rpx;
				height: 126rpx;
				position: relative;
				margin-right: 20rpx;

				.far {
					width: 126rpx;
					height: 126rpx;
					background: rgba(51, 51, 51, .3);
					box-shadow: 0 0 6rpx 0 rgba(51, 51, 51, .06);
					border-radius: 30rpx 10rpx 30rpx 10rpx;
					position: absolute;
					left: 0;
					bottom: 0;
					font-size: 20rpx;
					font-weight: 400;
					color: #fff;
					text-align: center;
					line-height: 126rpx;
				}

				.state {
					position: absolute;
					left: 50%;
					bottom: 0;
					-webkit-transform: translate(-50%, 50%);
					transform: translate(-50%, 50%);

					>view {
						display: block;
						white-space: nowrap;
						font-size: 9px;
						font-weight: 400;
						color: #fff;
						width: 45px;
						height: 15px;
						text-align: center;
						line-height: 15px;
						border-radius: 7px;
						background: #5cad08;
					}
				}
			}

			.head-img {
				width: 100%;
				height: 100%;
				border-radius: 30rpx 10rpx 30rpx 10rpx;
			}
		}

		.item-right {
			flex: 1;

			.t_right_btn {
				width: 110rpx;
				height: 50rpx;
				line-height: 50rpx;
				text-align: center;
				white-space: nowrap;
				background: linear-gradient(90deg, #d7b075, #aa8050);
				border-radius: 24rpx;
				font-size: 24rpx;
				font-weight: 400;
				color: #fff;

				&::after {
					border: none;
				}
			}

			.t_left {
				flex: 1;

				.t_certificate_order {
					margin-bottom: 10rpx;
					font-size: 11px;
					font-weight: 400;
					color: #666;

					.t_store {
						color: #666;
						font-size: 24rpx;
						margin-bottom: 20rpx;

						&::before {
							content: '';
							width: 28rpx;
							height: 28rpx;
							background: url(/static/shop-icon.png) no-repeat;
							background-size: 100% auto;
							margin-right: 2px;
						}

						&::after {
							content: '\e65f';
							font-weight: bold;
							font-size: 20rpx;

						}
					}

					.t_certificate {
						font-size: 24rpx;
						font-weight: 400;
						color: #666;
						margin-right: 30rpx;

						&::before {
							content: '';
							width: 28rpx;
							height: 28rpx;
							background: url(/static/certification.png) no-repeat;
							background-size: 100% auto;
							margin-right: 2px;
						}

						&::after {
							content: '\e65f';
							font-weight: bold;
							font-size: 20rpx;

						}
					}
				}
			}

			.t_name_tag_distance {
				margin-bottom: 16rpx;
				height: 38rpx;
				justify-content: space-between;



				.uni-label-pointer {
					font-size: 28rpx;
					font-weight: 500;
					color: #333;
					margin-right: 10rpx;
				}

				.t_tag {
					font-size: 24rpx;
					font-weight: 400;
					color: #e9560c;
				}

				.t_distance {
					font-size: 24rpx;
					font-weight: 400;
					color: #666;
				}
			}
		}

		.technician-item {
			width: 100%;
			box-sizing: border-box;
			background: #fff;
			padding: 24rpx 28rpx 30rpx;
			margin-bottom: 10rpx;
			align-items: flex-start !important;

			.left {
				width: 126rpx;
				height: 126rpx;
				position: relative;
				margin-right: 20rpx;

				image {
					width: 100%;
					height: 100%;
					box-shadow: 0 0 6rpx 0 rgba(51, 51, 51, .06);
					border-radius: 15px 5px 15px 5px;
				}

				.state {
					position: absolute;
					left: 50%;
					bottom: 0;
					-webkit-transform: translate(-50%, 50%);
					transform: translate(-50%, 50%);

					text {
						display: block;
						white-space: nowrap;
						font-size: 18rpx;
						font-weight: 400;
						color: #fff;
						width: 90rpx;
						height: 30rpx;
						text-align: center;
						line-height: 30rpx;
						border-radius: 15rpx;
						background: #5cad08;
					}
				}
			}

			.right {
				flex: 1;
			}
		}
		.technician-list_photos {
			padding: 20rpx 0 24rpx 170rpx;
			background: #fff;
			margin-bottom: 10rpx;
			overflow: hidden;
		}
		.technician-list_photos .cells{
			width: 100%;
			white-space: nowrap;
			overflow-x: scroll;
		}
		.technician-list_photos .cell {
			display: inline-block;
			width: 170rpx;
			height: 170rpx;
			background: #d8d8d8;
			box-shadow: 0 0 6rpx 0 rgba(0, 0, 0, .06);
			border-radius: 16rpx;
			margin-right: 16rpx;
			position: relative;
			overflow: hidden;
		}
	}
</style>
